package com.qf.controller;

import com.qf.pojo.req.JqOrderReq;
import com.qf.pojo.resp.BaseResp;
import com.qf.service.JqOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * @author WYD
 * @date 2021/10/26  8:54
 */
@Api(value = "查询订单",tags = "查询订单")
@RequestMapping("/jqOrder")
@RestController
public class XcJqOrderController {

    @Autowired
    JqOrderService jqOrderService;

    /**
     * 生成订单
     * @param jqOrderReq 订单实体类
     * @param httpServletRequest
     * @return
     */
    @ApiOperation("生成订单")
    @RequestMapping(value = "/addOrder",method = RequestMethod.POST)
    public BaseResp addOrder(@ApiParam(name = "order", value = "order", required = true)
            @RequestBody JqOrderReq jqOrderReq, HttpServletRequest httpServletRequest){
        return jqOrderService.addOrder(jqOrderReq,httpServletRequest);
    }

    /**
     * 查询订单
     * @param request
     * @return
     */
    @ApiOperation("查询订单")
    @RequestMapping(value = "/findXcOrderById",method = RequestMethod.GET)
    public BaseResp findXcOrderById(HttpServletRequest request){
        return jqOrderService.findXcOrderById(request);
    }

    @ApiOperation("查询所有订单包括已支付订单")
    @RequestMapping(value = "/findXcOrderByIdAll",method = RequestMethod.GET)
    public BaseResp findXcOrderByIdAll(HttpServletRequest request){
        return jqOrderService.findXcOrderByIdAll(request);
    }

    /**
     * 取消订单
     * @param orderId
     * @return
     */
    @ApiOperation("取消订单")
    @RequestMapping(value = "/cancelOrder/{orderId}",method = RequestMethod.GET)
    public BaseResp cancelOrder(@PathVariable("orderId") String orderId){
        return jqOrderService.cancelOrder(orderId);
    }

}
